import("io", true);
import("MPI");

Rank = MPI.Rank();
Size = MPI.Size();

ArraySize = 4096;

// Build data
if (Rank == 0) {
    DataArray = new Array(ArraySize);
    for (i=0; i<ArraySize; i++)
        DataArray[i] = Math.round(Math.random()) ? "Hey everyone here's a string!" : 42;
}
else
    DataArray = false;

// Broadcast data
DataArray = MPI.Bcast(0, DataArray);

// Check data
hasErrors = false;
for (i=0; i<ArraySize; i++) {
    if (DataArray[i] != 42 && DataArray[i] != "Hey everyone here's a string!" ) {
        hasErrors = true;
        print(DataArray[i]);
    }
}

if (hasErrors)
    print( MPI.Rank() + ": Error" );
else
    print( MPI.Rank() + ": Okay" );

